import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;



class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode() {}
      TreeNode(int val) { this.val = val; }
      TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
 }

public class Test {
    public static String func() {
        String str1 = "abc";
        String str2 = "def";
        return str2+str1;
    }
    public static void main(String[] args) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(1);

        String str1 = "abc";
        String str2 = "def";
        List<String> list = new LinkedList<>();
        list.add(str1+str2);
        System.out.println(list.get(0));

        String str3 = func();
        list.add(str3);
        System.out.println(list.get(1));


        int a = 1;
        String ss = String.valueOf(a);
        System.out.println(ss);

    }
    //257.求二叉树所有路径
    List<String> list = new LinkedList<>();
    //先序遍历
    public List<String> binaryTreePaths(TreeNode root) {
        dfs(root,"");
        return list;
    }
    public void dfs(TreeNode root,String prev) {
        if(root == null) return;
        if(root.left == null && root.right ==null) {
            list.add(prev+String.valueOf(root.val));
            return;
        }
        String now = prev+String.valueOf(root.val)+"->";
        dfs(root.left,now);
        dfs(root.right,now);

    }


}
